package com.bac.rentmap.web.controller.flataddao;

import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractCommandController;
import org.springframework.web.servlet.mvc.SimpleFormController;

import com.bac.rentmap.ad.flat.FlatAd;
import com.bac.rentmap.ad.flat.FlatAdDao;
import com.bac.rentmap.web.controller.ad.search.FlatAdSearchController;

public class FlatAdDaoController  extends SimpleFormController {
    private static final Logger log = Logger
        .getLogger(FlatAdSearchController.class.getName());
    private FlatAdDao flatAdDao;
  
    @Override
    protected ModelAndView onSubmit(Object command, BindException errors)
        throws Exception {
        FlatAd flatAdCommand = (FlatAd) command;
        log.info("Command" + flatAdCommand.getId());
        FlatAd flatAd = flatAdDao.get(flatAdCommand.getId());
        Map model = new HashMap();
        model.put("flatAdCommand", flatAdCommand);
        model.put("flatAd", flatAd);
        return new ModelAndView("admin/flatAdDao/index", model);
    }

    public void setFlatAdDao(FlatAdDao flatAdDao) {
      this.flatAdDao = flatAdDao;
    }
}
